<script>
import Header from "@/components/Header.vue"
import Modal from "@/components/Modal.vue"
export default {
	components: {
		Header,
		Modal
	},
	data() {
		return {
			modalShow: false,
			payType: 0,
			title: "我的资源库",
			Resource: [],
			count: 0,
			sex_arr: ['不限', '男', '女'],
			sex_str: '性别切换',
			sex: '',
			info: {}
		}
	},
	onLoad(options) {
		this.getMyResource()
		var info = uni.getStorageSync('info')
		this.info = info
	},
	onShow() {
		this.getMyResource();
	},
	methods: {
		avatarChange() {
			uni.showActionSheet({
				title: "更新头像",
				itemList: ["使用微信头像", "从相册选择", "拍照"]
			})
		},
		getMyResource() {
			var that = this
			uni.request({
				url: getApp().globalData.host + '/api/Resource/getMyResource',
				data: {
					page: 1, nums: 100, sex: that.sex
				},
				header: {
					memberid: uni.getStorageSync('member_id'),
					membertoken: uni.getStorageSync('member_token'),
				},
				success: (r) => {
					that.Resource = r.data.data.list
					that.count = r.data.data.all_num
				},
			})

		},
		edit(e) {
			var val = e.detail.value
			if (val == 0) {
				this.sex_str = '性别切换'
				this.sex = ''
			} else if (val == 1) {
				this.sex_str = '男'
				this.sex = 1
			} else {
				this.sex_str = '女'
				this.sex = 2
			}
			this.getMyResource();
		}
	}
}
</script>
<template>
	<view class="custom-bg container">

		<Header :title="title" />

		<div class="bg-white between px-30 py-20 flex-shirnk-0" style="color: #8c8c8c;">
			<div class="fz28">总计：{{ count }}人</div>
			<picker mode="selector" :range="['不限', '男', '女']" @change="edit">
				<div class="fz28">
					{{ sex_str }}
					<image src="/static/my/down.png" mode="widthFix" class="w-35 ml-20"></image>
				</div>
			</picker>
		</div>

		<div class="p-30 flex-1" style="overflow: auto;">
			<div class="bg-white rounded-20 py-30 px-25 mb-24" v-for="item in Resource"
				@click="go('/pages/my/resources/detail?id=' + item.resource_id + '&find=' + JSON.stringify(item))">
				<div class="between items-start">
					<div class="text-purple">
						-基本信息-
					</div>
					<div class="bg-purple text-white py-17 px-32 rounded-50">查看详细信息</div>
				</div>
				<div class="fz28 text-gray-16">
					<div class="mb-20">姓名：{{ item.resource_name }}</div>
					<div class="mb-20">性别：{{ item.resource_sex }}</div>
					<div class="mb-20">年龄：{{ item.resource_age }}</div>
					<div>录入时间：{{ item.add_time }}</div>
				</div>
			</div>
			<nomore v-if="Resource.length == 0"></nomore>

		</div>

		<div style="height: 150rpx;"></div>

		<div class="submit  text-white p-30 bg-white">
			<div class="bg-purple center h-90 rounded-50" @click="go('/pages/my/resources/form')">
				新增
			</div>
		</div>
	</view>


</template>



<style>
.container {
	height: 100%;
	display: flex;
	flex-direction: column;
}

.submit {
	position: fixed;
	bottom: 0;
	left: 0;
	width: 100%;
}

.custom-bg {
	min-height: 100%;
}

.avatar-group {
	position: relative;
}

page {
	height: 100%;
	background-color: #F8F8F8;
}
</style>